<template>
  <div class="app-container">
    <warehouseMoveOverviewDelRecordVue ref="openWarehouseMoveOverviewDelRecord" @refresh="refresh"></warehouseMoveOverviewDelRecordVue>
    <el-form @submit.native.prevent :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="120px" :label-position="labelPosition">
      <el-form-item label="单号" prop="pzbh">
        <el-input
          v-model="queryParams.pzbh"
          placeholder="请输入单号"
          clearable
           @keyup.enter.native="enterClick"
        />
      </el-form-item>
      <el-form-item label="业务日期" prop="warehouseMoveDate">
        <el-date-picker
            v-model="warehouseMoveDate"
            value-format="yyyy-MM-dd"
            type="daterange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            @change="warehouseMoveDateChange()">
            </el-date-picker>
      </el-form-item>
      <el-form-item label="客户" prop="khmc">
        <el-input
          v-model="queryParams.khmc"
          placeholder="请输入客户"
          clearable
           @keyup.enter.native="enterClick"
        />
      </el-form-item>
       <el-form-item label="条码" prop="sptm">
        <el-input
          v-model="queryParams.sptm"
          placeholder="请输入条码"
          clearable
           @keyup.enter.native="enterClick"
        />
      </el-form-item>      
      <el-form-item label="物品规格" prop="spzs">
        <el-input
          v-model="queryParams.spzs"
          placeholder="请输入物品规格"
          clearable
           @keyup.enter.native="enterClick"
        />
      </el-form-item>
      <el-form-item label="品牌" prop="spcd">
        <el-input
          v-model="queryParams.spcd"
          placeholder="请输入品牌"
          clearable
           @keyup.enter.native="enterClick"
        />
      </el-form-item>
      <el-form-item label="柜号/批号" prop="spgh">
        <el-input
          v-model="queryParams.spgh"
          placeholder="请输入柜号/批号"
          clearable
           @keyup.enter.native="enterClick"
        />
      </el-form-item>
      <el-form-item label="旧/新仓库" prop="status">
        <el-select
            v-model="queryParams.spckmc"
            placeholder="请选择旧/新仓库"
            clearable
            style="width: 240px"
            @change="changeWarehouse"
            :loading="selectWarehouse24Loading"
        >
            <el-option
                v-for="item in warehouseList"
                :key="item.spckid"
                :label="item.spckmc"
                :value="item.spckid"
            />
        </el-select>
      </el-form-item>      
      <el-form-item >
        <el-checkbox v-model="queryParams.jqcz" label="精确搜索" true-label="1" @change="getList"></el-checkbox>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
     <el-row :gutter="10" class="mb8">
        <el-col :span="1.5">
          <el-button  type="primary" plain size="mini" @click="deleteRecord()" v-hasPermi="['zhcloud:hwtc:list']">已删除记录</el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button type="primary" plain size="mini" @click="handleExport" v-hasPermi="['zhcloud:hwtc:export']">导出为Excel</el-button>
        </el-col>
    </el-row>
    <el-table
      v-loading="loading"
      :data="warehouseMoveList"
      :show-summary="false"
      ref="warehouseMoveTable"
    >
      <af-table-column label="单据号"  prop="pzbh" />
      <af-table-column label="物品规格"  prop="spzs" />
      <af-table-column label="批号"  prop="spbh" />
      <af-table-column label="柜号"  prop="spgh" />
      <af-table-column label="件数"  prop="spjs" />
      <af-table-column label="单重(KG)"  prop="spjsl" />
      <af-table-column label="重量(吨)"  prop="spsl" />
      <af-table-column label="业务日期"  prop="ssrqida" />
      <af-table-column label="旧仓库"  prop="spckmc" />
      <af-table-column label="旧仓位"  prop="ckcw" />
      <af-table-column label="新仓库"  prop="spckmc2" />
      <af-table-column label="新仓位"  prop="ckcw2" />
      <af-table-column label="品牌"  prop="spcd" />
      <af-table-column label="客户条码"  prop="sptm" />
      <af-table-column label="旧仓库条码"  prop="sptmc1" />
      <af-table-column label="新仓库条码"  prop="sptmc2" />
      <af-table-column label="所有者"  prop="AllName" />
      <af-table-column label="创建时间"  prop="prrq" />
      <af-table-column label="创建人"  prop="rsopmc" />
      <af-table-column label="入仓日期"  prop="ssrqid" />
      <af-table-column label="备注"  prop="itbz" width="150" :show-overflow-tooltip="true"/>
    </el-table>
     <pagination
        v-show="total>0"
        :total="total"
        :page.sync="pageNum"
        :limit.sync="pageSize"
        @pagination="getList"
      />
  </div>

</template>

<script>
import { getWarehouseMoveOverview }  from "@/api/storage/commonGoods/warehouseMove";
import { selectWarehouse24 } from "@/api/storage/warehouse"
import warehouseMoveOverviewDelRecordVue from "./warehouseMoveOverviewDelRecord.vue";

export default {
  name: "WarehouseMoveOverview",
  components: { warehouseMoveOverviewDelRecordVue },
  data() {
    return {
      // 显示搜索条件
      showSearch: true,
      // 对齐方式
      labelPosition:"right",
      //列表加载
      loading: true,
      // 仓库加载
      selectWarehouse24Loading: true,
      //审核状态
      auditState:[{
        value: "未审核",
        label:"未审核"
      },{
        value: "已审核",
        label:"已审核"
      }],
      warehouseMoveDate:'',
      // 查询参数
      queryParams: {
        dzzy6: "",
        isBa: "",
        jqcz: "",
        khmc: "",
        khpb: 0,
        pzbh: "",
        qycz: "",
        s1: "",
        s2: "",
        shopId: 0,
        shzt: "",
        spbh: "",
        spcd: "",
        spckidis: [],
        spckmc: "",
        spgh: "",
        spmc: "",
        sptm: "",
        spzs: "",
        wbdh: "",
        downloadType:"json"
      },
      //excel导出
       exportList: [],
      //获取仓位参数
      selectPositionQuery:{
         spckid:""
      },
      // 货物入仓列表
      warehouseMoveList: [],
      //仓库列表
      warehouseList:[],
      //页数
      pageSize: 10,
      //页码
      pageNum:1,
      // 总条数
      total: 0,
    };
  },
  created() {
    this.getWarehouse()
    this.getList();
  },
  methods: {
    /**获取仓库 */
    getWarehouse() {
      this.selectWarehouse24Loading = true
      selectWarehouse24({}).then(response => {
        this.warehouseList = response.data
        this.selectWarehouse24Loading = false
      });
    },
    /** 查询货物调仓总览 */
    getList() {
      this.loading = true
      getWarehouseMoveOverview(this.queryParams, {pageNum:this.pageNum, pageSize:this.pageSize}).then(response => {
        this.warehouseMoveList = response.rows;
        this.total = response.total;
        this.loading = false
      });
    },

    /**选择仓库 */
    changeWarehouse(row) {
      this.selectPositionQuery.spckid = row
      this.getList()
    },

    /**选择审核状态 */
    changeWarehouseAuditState() {
      this.getList()
    },

     /**业务日期 */
    warehouseMoveDateChange() {
      this.queryParams.s1 = this.warehouseMoveDate[0]
      this.queryParams.s2 = this.warehouseMoveDate[1]
      this.getList()
    },

    /** 搜索按钮操作 */
    handleQuery() {
      this.pageNum = 1
      this.getList();
    },

    /** 删除记录*/
    deleteRecord() {
      this.$refs.openWarehouseMoveOverviewDelRecord.open()
    },

    /** 导出勾选数据*/
    handleExport() {
      this.download('/storage/hwtc/export', this.queryParams, `货物调仓总览_${new Date().getTime()}.xlsx`)
    },
       /**enter键触发 */
    enterClick(e) {
      this.getList()
    },

    /** 刷新数据*/
    refresh() {
      this.getList()
    },
     /** 重置按钮操作 */
    resetQuery() {
      this.reset()
      this.getWarehouse()
      this.getList()
    },
    reset() {
      Object.assign(this.$data, this.$options.data())
    },
  }
};
</script>
